#Set-up
rm(list=ls())
#library(coda)
#library(lattice)
#library(rjags)
#library(xtable)
#library(gmodels)
#setwd('/Users/monogan/Documents/looseData/coda2016/')
#setwd('/Users/jamie/looseData/coda2016/')
#setwd('C:/Users/monogan/Desktop/coda2016')
#setwd("/Volumes/MONOGAN/psrsd/anxiety2016/")
#setwd("/Users/monogan/Documents/psrsd/anxiety2016/data/REPLICATION/")

 
#party by anxiety interactions
pid.anx<-matrix(NA,nrow=9,ncol=3)
rownames(pid.anx)<-c(1984,1988,1992,1996,2000,2004,2008,2012,2016)
colnames(pid.anx)<-c("Mean","5%","95%")
pid.anx[1,]<-c( -3.740 , -7.234 , -0.283)#84
pid.anx[2,]<-c(-3.544 , -6.856 , -0.220 )#88
pid.anx[3,]<-c( -2.678 , -6.247 , 0.934)#92
pid.anx[4,]<-c( -3.276 , -6.688 , 0.088)#96
pid.anx[5,]<-c( -1.757 ,-5.386 , 1.918)#00
pid.anx[6,]<-c( -3.417 , -7.012 , 0.167)#04
pid.anx[7,]<-c( -3.078 , -6.914 , 0.717)#08
pid.anx[8,]<-c( -9.470 , -12.078 , -6.905)#12
pid.anx[9,]<-c( -8.007 , -10.668 , -5.407)#16

#pdf("anxPidTime.pdf",pointsize=8,width=4,height=4)
plot(y=1:9,x=pid.anx[,"Mean"],xlab="Coefficient",ylab="",axes=F,xlim=c(min(pid.anx),max(pid.anx)),main="Partisanship x Anxiety")
axis(1);axis(2,at=1:9,labels=c(1984,1988,1992,1996,2000,2004,2008,2012,2016),las=1)
abline(v=0,col='gray60');box()
arrows(x0=pid.anx[,"5%"],x1=pid.anx[,"95%"],y0=1:9,y1=1:9,length=0)
#dev.off()

#issue by anxiety interactions
issue.anx<-matrix(NA,nrow=9,ncol=3)
rownames(issue.anx)<-c(1984,1988,1992,1996,2000,2004,2008,2012,2016)
colnames(issue.anx)<-c("Mean","5%","95%")
issue.anx[1,]<-c( 1.767 , -2.262 , 5.810)#84
issue.anx[2,]<-c(3.021 , -1.006 , 7.091 )#88
issue.anx[3,]<-c( 2.215 , -2.132, 6.459)#92
issue.anx[4,]<-c( 2.961 ,-1.357 , 7.229)#96
issue.anx[5,]<-c( 1.819 , -2.530 , 6.123)#00
issue.anx[6,]<-c( 3.295 , -1.031 , 7.603)#04
issue.anx[7,]<-c( 2.241 , -1.922 , 6.436 )#08
issue.anx[8,]<-c( 3.652 , -0.028 , 7.417)#12
issue.anx[9,]<-c( 1.405 , -2.429 , 5.172)#16

#pdf("anxIssueTime.pdf",pointsize=8,width=4,height=4)
plot(y=1:9,x=issue.anx[,"Mean"],xlab="Coefficient",ylab="",axes=F,xlim=c(min(issue.anx),max(issue.anx)),main="Issues x Anxiety")
axis(1);axis(2,at=1:9,labels=c(1984,1988,1992,1996,2000,2004,2008,2012,2016),las=1)
abline(v=0,col='gray60');box()
arrows(x0=issue.anx[,"5%"],x1=issue.anx[,"95%"],y0=1:9,y1=1:9,length=0)
#dev.off()

#personal quality by anxiety interactions
pers.anx<-matrix(NA,nrow=9,ncol=3)
rownames(pers.anx)<-c(1984,1988,1992,1996,2000,2004,2008,2012,2016)
colnames(pers.anx)<-c("Mean","5%","95%")
pers.anx[1,]<-c( 1.440 , -2.496 , 5.388)#84
pers.anx[2,]<-c(2.822 , -1.343 , 6.957)#88
pers.anx[3,]<-c( 3.369 , -0.780 , 7.576)#92
pers.anx[4,]<-c( 4.521 , 0.301 , 8.669)#96
pers.anx[5,]<-c( 3.133 , -1.137 , 7.419)#00
pers.anx[6,]<-c(3.029 , -1.183 , 7.263)#04
pers.anx[7,]<-c( 3.627 , -0.626 , 7.937)#08
pers.anx[8,]<-c( 3.606 , -0.439 , 7.703 )#12
pers.anx[9,]<-c( 6.478 , 2.255 , 10.636)#16

#pdf("anxPersonalTime.pdf",pointsize=8,width=4,height=4)
plot(y=1:9,x=pers.anx[,"Mean"],xlab="Coefficient",ylab="",axes=F,xlim=c(min(pers.anx),max(pers.anx)),main="Personal Qualities x Anxiety")
axis(1);axis(2,at=1:9,labels=c(1984,1988,1992,1996,2000,2004,2008,2012,2016),las=1)
abline(v=0,col='gray60');box()
arrows(x0=pers.anx[,"5%"],x1=pers.anx[,"95%"],y0=1:9,y1=1:9,length=0)
#dev.off()
